import dt from '@dt/dt'
import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'

function options(_this) {
  return [{
      type: 'index',
      title: '序号',
      minWidth: 60
    },
    {
      field: 'allowanceName',
      title: '津贴名称',
      minWidth: 200
    },
    {
      field: 'allowanceTypeStr',
      title: '津贴类型',
      minWidth: 150
    },
    {
      field: 'allowanceMoney',
      title: '津贴总额(元)',
      minWidth: 150,
    },
    {
      field: 'allowanceMonth',
      title: '发放月份',
      minWidth: 80
    },
    {
      field: 'createTime',
      title: '创建日期',
      minWidth: 120,
    },

    {
      field: 'statusStr',
      title: '状态',
      minWidth: 140,
    },
    {
      field: 'nextReviewer',
      title: '当前审批节点',
      minWidth: 140,
    },

    {
      field: 'handles',
      title: '操作',
      width: 230,
      fixed: 'right',
      slots: {
        default: (params, h) => {
          let btns = []
          let item = params.row
          if (item.status == 'UNSUBSTITUTED') {
            btns.push({
              title: _this.unlocking('0112030500') ? '查看' : '',
              event: 'allowanceSee',
              data: item
            })
            btns.push({
              // title: _this.unlocking('0111010400') ? '打开' : '',
              // residence全部，UNSUBSTITUTED 未提交，APPROVAL 审批中，PASS 通过，NO_PASS 驳回，WITHDRAWN 撤回。
              title: _this.unlocking('0112030200') ? '编辑' : '',
              event: 'allowanceEdit',
              data: item
            })
            btns.push({
              title: _this.unlocking('0112030300') ? '删除' : '',
              event: 'allowanceDelete',
              data: item
            })
          } else if (item.status == 'APPROVAL') {
            btns.push({
              title: _this.unlocking('0112030500') ? '查看' : '',
              event: 'allowanceSee',
              data: item
            })
            btns.push({
              title: _this.unlocking('0112030600') ? '撤回' : '',
              event: 'allowanceWithdraw',
              data: item
            })
            btns.push({
              title: '流程信息',
              event: 'allowanceProcess',
              data: item
            })
          } else if (item.status == 'PASS') {
            btns.push({
              title: _this.unlocking('0112030500') ? '查看' : '',
              event: 'allowanceSee',
              data: item
            })
            btns.push({
              title: '流程信息',
              event: 'allowanceProcess',
              data: item
            })
          } else if (item.status == 'NO_PASS' || item.status == 'WITHDRAWN') {
            btns.push({
              title: _this.unlocking('0112030500') ? '查看' : '',
              event: 'allowanceSee',
              data: item
            })
            btns.push({
              title: _this.unlocking('0112030400') ? '重新发起' : '',
              event: 'allowanceRelaunch',
              data: item
            })
            btns.push({
              title: '流程信息',
              event: 'allowanceProcess',
              data: item
            })
            btns.push({
              title: _this.unlocking('0112030300') ? '删除' : '',
              event: 'allowanceDelete',
              data: item
            })
          }
          return table.cell.btns(_this, h, btns)
        }
      }
    }
  ]
}

export default {
  options
}